/*
* Copyright (c) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Camerality OpenGL rendering based view implementation.
*
*/

// INCLUDE FILES
#include <math.h>
#include <akndef.h>
#include <aknappui.h>
#include "cameralitytraces.h"
#include "cameralityglrenderer.h"
#include "cameralityglcontainer.h"

// ================= MEMBER FUNCTIONS =======================

/*!
* Two-phased constructor.
* @return Container instance.
*/
CCameralityGLContainer* CCameralityGLContainer::NewL()
    {
    CCameralityGLContainer* self = new (ELeave) CCameralityGLContainer();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

/*!
* Constructor.
*/
CCameralityGLContainer::CCameralityGLContainer()
    {
    }


/*!
* Second phase constructor.
*/
void CCameralityGLContainer::ConstructL()
    {
    DoConstructL();
    iRenderer = CCameralityGLRenderer::NewL();
    }

/*!
* Destructor.
* Releases any used resources.
*/
CCameralityGLContainer::~CCameralityGLContainer()
    {
    TRACE_ENTER();
    delete iRenderer;
    TRACE_EXIT();
    }

/*!
* Called by framework when the view size is changed.
*/
void CCameralityGLContainer::SizeChanged()
    {
    if (iRenderer)
        {
        iRenderer->Resize(Size());
        }
    }

/*!
* Normal CCoeControl drawing method. Does nothing in this class,
* as all drawing is done in the RenderScene() method.
*/
void CCameralityGLContainer::Draw(const TRect& /*aRect*/) const
    {
    TRACE_ENTER();
    TRACE_EXIT();
    }

/*!
* Show this control.
*/
void CCameralityGLContainer::Show(const TRect& extent)
    {
    TRACE_ENTER();
    CCameralityBaseContainer::Show(extent);
    if (iRenderer)
        {
        iRenderer->Start(Window());
        }

    TRACE_EXIT();
    }

/*!
* Hide this control.
*/
void CCameralityGLContainer::Hide()
    {
    if (iRenderer)
        {
        iRenderer->Stop();
        }
    CCameralityBaseContainer::Hide();
    }


CCameralityGLRenderer* CCameralityGLContainer::Renderer() const
    {
    return iRenderer;
    }

// End of File
